package Io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class PersonDemo {
    public static void main(String[] args) throws IOException {
        Person p = new Person();
        p.age=5;
        p.name="赵海帆";
        p.dizhi="重庆";
        System.out.println(p);
        FileOutputStream fos = new FileOutputStream("");
        ObjectOutputStream obs = new ObjectOutputStream(fos);
        /*
        序列化对象输出时可能抛出异常，可能是没有继承Serializable接口
         */
        obs.writeObject(p);
        fos.close();
        obs.close();
    }
}
